<?php

use lujie\proxy\HttpProxyServer;
use lujie\proxy\Socks5ProxyServer;
use Workerman\Worker;

defined('APP_BASE_PATH') or define('APP_BASE_PATH', '/app');

require_once APP_BASE_PATH . '/vendor/autoload.php';

$httpProxyServer = new HttpProxyServer('tcp://0.0.0.0:1080');
$socks5ProxyServer = new Socks5ProxyServer('tcp://0.0.0.0:1088');
$configFile = APP_BASE_PATH . '/config.php';
if (file_exists($configFile)) {
    $config = require_once $configFile;
    $httpProxyServer->authEnabled = $config['http.authEnabled'] ?? false;
    $httpProxyServer->username = $config['http.username'] ?? 'http.username';
    $httpProxyServer->password = $config['http.password'] ?? 'http.password';
    $httpProxyServer->count = $config['http.count'] ?? 1;
    $socks5ProxyServer->authEnabled = $config['socks5.authEnabled'] ?? false;
    $socks5ProxyServer->username = $config['socks5.username'] ?? 'socks5.username';
    $socks5ProxyServer->password = $config['socks5.password'] ?? 'socks5.password';
    $socks5ProxyServer->count = $config['socks5.count'] ?? 1;
}

Worker::$logFile = '/var/log/workerman.log';
Worker::$pidFile = '/var/run/workerman.pid';

Worker::runAll();
